package A1;

import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;

import java.security.MessageDigest;
import java.util.Arrays;
public class a {
    public static void main(String[] args) {


//        -0110 0100
//              1111
    }
    public static String getMD5Str(String str) {
        byte[] digest = null;
        try {
            MessageDigest md5 = MessageDigest.getInstance("md5");
            digest  = md5.digest(str.getBytes("utf-8"));
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        //16是表示转换为16进制数
        String md5Str = new BigInteger(1, digest).toString(16);
        return md5Str;
    }
    public static String fmd5(String md5){
        StringBuilder str = null;
        char a;
//        while (true){
//        for (int i=0;i<=150;i++){
//            a = (char) i;
//            System.out.println(i+"="+a);
//            str.append(a);
//            break;
//        }
//    }
        return str.toString();
    }
    public static String md5(String source) {
        char[] hexDigits = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
        source+="com.shtd";
        try {
            byte[] btInput = source.getBytes("utf-8");
            MessageDigest mdInst = MessageDigest.getInstance("MD5");
            mdInst.update(btInput);

            byte[] md = mdInst.digest();
            System.out.println(Arrays.toString(md));
            int j = md.length;
            System.out.println(j);
            char[] str = new char[j * 2];
            int k = 0;
            for(int i = 0; i < j; ++i) {
                byte byte0 = md[i];
                str[k++] = hexDigits[byte0 >>> 4 & 15];
                str[k++] = hexDigits[byte0 & 15];
                System.out.println(byte0);
                System.out.println(byte0 & 15);

            }

            return (new String(str)).toLowerCase();
        } catch (Exception var10) {
            var10.printStackTrace();
            return null;
        }
    }
}